/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

//键盘控件
#import "IQKeyboardManager.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"project806"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
//  UIView * launchScreenView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] objectAtIndex:0];
//  launchScreenView.frame = self.window.bounds;
//  rootView.loadingView = launchScreenView;
  
  //键盘控件
  [self configIQKeyboardManager];
  
  return YES;
}

//键盘控件
-(void)configIQKeyboardManager{
  [IQKeyboardManager sharedManager].enable = YES;
  [[IQKeyboardManager sharedManager] setToolbarTintColor:[UIColor colorWithRed:58/255.0 green:125/255.0 blue:218/255.0 alpha:1]];
  [IQKeyboardManager sharedManager].toolbarDoneBarButtonItemText = @"完成";
  [IQKeyboardManager sharedManager].shouldShowToolbarPlaceholder = true;
  [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;//键盘弹出时，点击背景，键盘收回
}


- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
//  return [[NSBundle mainBundle] URLForResource:@"bundle/index" withExtension:@"jsbundle"];
#endif
}

@end
